// 获取所有的cookie并且转为对象
export const getCookies = () =>
  document.cookie
    .split(';')
    .map((item) => item.split('='))
    .reduce((acc, [k, v]) => (acc[k.trim().replace('"', '')] = v) && acc, {})

// 清除所有的cookie
export const clearCookies = () =>
  document.cookie
    .split(';')
    .forEach(
      (c) => (document.cookie = c.splace(/^+/, '').replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`))
    )
